<include file="public:head" />
<style type="text/css">
::selection {
    color:#fff;
    background-color: #2f549f !important;
}

::-moz-selection {
    color:#fff;
    background-color: #2f549f !important;
}

::-webkit-selection {
    color:#fff;
    background-color: #2f549f !important;
}
</style>
  <!-- 二级页次级导航 -->
<include file="public:sep" />
<!-- 二级页次级导航结束 -->

<!-- 主体开始 -->
<div class="layui-container">
  <div class="layui-row layui-col-space15">

    <!-- 左侧开始 -->
    <div class="layui-col-md9 content detail">
      <div class="fly-panel detail-box mb0 pb5">
        <!-- 文档头部 -->
        <h2 style="width: 80%;"><i class="ic ic-{$info.ext|strtolower}" style="top: -2px;"></i>{$info.title}</h2> 
        <div class="jubaodiv">
          <if condition="$jubao neq ''">
          <span class="layui-btn layui-btn-xs jubao jubao-active layui-btn-primary">已举报</span>
          <else />
          <span class="layui-btn layui-btn-xs jubao">举报</span>
          </if>
          <if condition="$hasxh neq ''">
          <span class="layui-btn layui-btn-xs shop-collect shop-collect-active layui-btn-primary">已收藏</span>
          <else />
          <span class="layui-btn layui-btn-xs layui-bg-blue shop-collect">收藏</span>
          </if>
        </div>
          
        <div class="fly-detail-info">
          <dd>
            <if condition="$info.status eq 4"><span class="layui-badge jinghua">精华</span></if>
            <span>{$info.intro}</span>
          </dd>
        </div>
        
        <!-- 文档头部结束 -->
      </div>


      <!-- 文档内容开始 -->

        <!-- 主内容 -->
        <if condition="$ipstr">
        <div class="fly-panel detail-box doccon mb0">
          {$ipstr}
        </div>

        <!-- 预览结束 购买文档 -->
        <if condition="$download eq 2 && $info.score gt '0' && $info.uid != $uid">
        <div class="fly-panel detail-box doccon buydiv mb0">
          <p >免费试读已结束，如果需要继续阅读或下载，请您购买</p>
          <p>本文档需要 <span style="color: #FF5722">{$info.score}{:C('wkcms_score_name')}</span></p>
          <p><button id="buybuy" class="layui-btn buybtn layui-btn-danger">{:C('wkcms_score_name')}购买</button></p>
        </div>
        <else />
        <!-- 翻页 -->
        <div id="read_more" class="fly-panel detail-box doccon fanye mb0" style="display: none;">
          <a href="javascript:;">还剩<span id="read_more_page">{$info.page}</span>页未读，点击继续 <i class="layui-icon">&#xe61a;</i></a>
        </div>
        
        </if>
        <else />
        <!-- 加载中 -->
        <div class="fly-panel detail-box doccon loading mb0">
          <i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop">&#xe63d;</i>   
          <p>文档正在努力转换中,请耐心等候</p>
        </div>
        </if>

        <!-- 文档内容结束 -->

      <!-- 回帖开始 -->
      <div class="fly-panel detail-box mtop15">
        <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
          <legend>讨论</legend>
        </fieldset>
        <empty name="commentdata['list']">
          <li class="fly-none">消灭零回复</li>
        </empty>
        <ul class="jieda" id="jieda">
          <volist name="commentdata['list']" id="vo">
          <li class="jieda-daan">
            <div class="detail-about detail-about-reply">
              <a class="fly-avatar userinfo" href="">
                <img src="{:C('wkcms_site_url')}{$vo['uid']|getavatar}" alt="{$vo.uid|getusername}">
              </a>
              <div class="fly-detail-user">
                <a href="" class="fly-link"><cite>{$vo.uid|getusername}</cite></a>             
              </div>
              <div class="detail-hits">
                <span>{$vo.add_time|fdate}</span>
              </div>
            </div>
            <div class="detail-body jieda-body photos">
              <p>{$vo.info|htmlspecialchars_decode}</p>
            </div>
          </li>
          </volist>
       
        </ul>
        
        <div class="layui-form layui-form-pane">
          <form method="post">
            <input type="hidden" name="itemid" value="{$id}" />
            <input type="hidden" name="commentid" value="{$commentcount}" />
            <input type="hidden" name="toid" id="toid" value="0" />
            <input type="hidden" name="uid" value="{$uid}" />
            <input type="hidden" name="typeid" value="1" />
            <div class="layui-form-item layui-form-text">
              <a name="comment"></a>
              <div class="layui-input-block">
                <textarea name="info" id="info" required lay-verify="required" placeholder="请登录后发表评论"  class="layui-textarea" style="height: 150px;"></textarea>
              </div>
            </div>
            <div class="layui-form-item">
              <input type="hidden" name="jid" value="123">
              <button class="layui-btn" id="comment">发评论</button>
            </div>
          </form>
        </div>
      </div>
    </div>
    <!-- 回帖开始结束 -->
    <!-- 左侧结束 -->

    <!-- 右侧开始 -->
    <div class="layui-col-md3">
      <!-- 文档信息 -->
      <div class="fly-panel">
        <div class="fly-panel-title">
          <span class="conxing" id="function-star2"></span><span class="fr fingfen"><span id="hint">{$raty['s']}</span>.{$raty['g']}分</span>
        </div>
        <div class="fly-panel-main docinfo">
           <ul class="layui-timeline">
              <li class="layui-timeline-item pb5">
                <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                <div class="layui-timeline-content layui-text">
                  <div class="layui-timeline-title"><span>贡献者：{$info['uid']|getusername} </span></div>
                </div>
              </li>
              
              <li class="layui-timeline-item pb5">
                <i class="layui-icon font12 layui-timeline-axis">&#xe63f;</i>
                <div class="layui-timeline-content layui-text">
                  <div class="layui-timeline-title"><span>售价：{$info.score} {:C('wkcms_score_name')} </span></div>
                </div>
              </li>
              <li class="layui-timeline-item pb5">
                <i class="layui-icon font12 layui-timeline-axis">&#xe63f;</i>
                <div class="layui-timeline-content layui-text">
                  <div class="layui-timeline-title"><span>时间：{$info.add_time|fdate}</span></div>
                </div>
              </li>
              <li class="layui-timeline-item pb5">
                <i class="layui-icon font12 layui-timeline-axis">&#xe63f;</i>
                <div class="layui-timeline-content layui-text">
                  <div class="layui-timeline-title"><span>大小：{$info['filesize'] / '1024'|round=###,0}KB</span></div>
                </div>
              </li>
              <li class="layui-timeline-item pb5">
                <i class="layui-icon font12 layui-timeline-axis">&#xe63f;</i>
                <div class="layui-timeline-content layui-text">
                  <div class="layui-timeline-title"><span>页数：{$info.page}页</span></div>
                </div>
              </li>
              <li class="layui-timeline-item pb5">
                <i class="layui-icon font12 layui-timeline-axis">&#xe63f;</i>
                <div class="layui-timeline-content layui-text">
                  <div class="layui-timeline-title"><span>浏览：{$info.hits}</span></div>
                </div>
              </li>
              <li class="layui-timeline-item pb5">
                <i class="layui-icon font12 layui-timeline-axis">&#xe63f;</i>
                <div class="layui-timeline-content layui-text">
                  <div class="layui-timeline-title"><span>下载：{$downnum}</span></div>
                </div>
              </li>
            </ul>
            <if condition="$download eq 2 && $info.score gt '0' && $info.uid != $uid">
             <button class="layui-btn layui-btn-fluid layui-btn-danger" type="submit" style="width: 100%;" id="buy">购买本文档 (<if condition="$info.score gt '0'">{$info.score}{:C('wkcms_score_name')}<else />免费</if>)</button>
             <else />
             <button class="layui-btn layui-btn-fluid layui-btn-normal" type="submit" style="width: 100%;" id="download">下载本文档 (<if condition="$info.score gt '0'">{$info.score}{:C('wkcms_score_name')}<else />免费</if>)</button>
            </if>
           

        </div>
      </div>
      <!-- 文档信息结束 -->

      <dl class="fly-panel fly-list-one">
        <dt class="fly-panel-title">编辑推荐</dt>
        <wkcms:doc type="lists" status="4"  order="add_time desc" >
        <empty name="data['list']">
            <div class="fly-none">没有相关数据</div>
        </empty>
        <volist name="data['list']" id="vo" offset="0" length="10">
        <dd>
          <a href="{:U('doc/doccon',array('id'=>$vo['id']))}"><i class="ic ic-{$vo.ext|strtolower}"></i> {$vo.title} </a>
          <span><i class="iconfont icon-liulanyanjing"></i>&nbsp;{$vo.hits}</span>
        </dd>
        </volist>
        </wkcms:doc>
      </dl>

      <!-- 广告 -->
      <div class="fly-panel">
        <div class="fly-panel-main">
           {:R('advert/index', array(15), 'Widget')} 
        </div>
      </div>
      <!-- 广告结束 -->

      <include file="public:flink" />

    </div>
    <!-- 右侧开始结束 -->
  </div>
</div>

<include file="public:footer" />
<script src="__PUBLIC__/theme/blueideal/mods/jquery.min.js"></script> 
<script src="__PUBLIC__/js/raty/jquery.raty.min.js"></script> 
<script>

function star()
{
    $('#function-star2').raty(
    {
        target    : '#hint',
        targetType: 'number',
        targetKeep : true,
        path : '__PUBLIC__/js/raty/img/',
        width : 150,
        //precision: true 
        score: {$info.ratystar},
        click: function(score, evt) {
            var send = {};
            send.score = score;
            send.id = {$info.id};
            var loading = layer.msg('操作中...', { icon: 16 ,shade: 0.01 });
            $.post("{:U('doc/setscore')}",send,function(res) {
                layer.close(loading);
                if (res.status == 1) {
                    layer.msg('评分成功',{time:1800});
                } else {
                    layer.msg(res.msg,{time:1800});
                }
            });
        }
    });
}
//评论
var layedit;
var layedit_index;
//初始化编辑器
layui.use('layedit', function(){
  layedit = layui.layedit ;
  layedit_index = layedit.build('info', {
    tool: ['face']
    ,height: 100
  })
});
function comment(e)
{
    var itemid = '{$id}';
    var commentid = '{$commentcount}';
    var info = layedit.getContent(layedit_index);//获取内容 
    var toid = 0;
    var uid = '{$uid}';
    var typeid = 1;
    if (!info) {
        layer.msg('请填写评论内容',{time:1800});
        return;
    }
    var send = {};
    send.itemid = itemid;
    send.commentid = commentid;
    send.info = info;
    send.toid = toid;
    send.uid = uid;
    send.typeid = typeid;

    var loading = layer.msg('操作中...', { icon: 16 ,shade: 0.01 });
    $.post("{:U('common/ajaxadd_comment')}",send,function(res) {
        layer.close(loading);
        if (res.status == 1) {
            layer.msg('评论成功',{time:1800}, function() {
                location.reload();
            });
        } else {
            layer.msg(res.msg,{time:1800});
        }
    });
}

function download(e)
{
    var send = {};
    send.id = '{$id}';
    var url = "{:U('doc/showdownload')}";
    $.post(url,send,function(res) {
        layer.open({
          type: 1
          ,title: '下载文档'
          ,area: '330px'
          ,shade: 0.1
          ,shadeClose: true
          ,content: [res.data].join('')
        });
    });
}

function buy(e)
{
    var send = {};
    send.id = '{$id}';
    var url = "{:U('doc/showbuy')}";
    $.post(url,send,function(res) {
        layer.open({
          type: 1
          ,title: '购买文档'
          ,area: '330px'
          ,shade: 0.1
          ,shadeClose: true
          ,content: [res.data].join('')
        });
        $("#buy_action").click(function()
        {
            buy_action($(this));
        })
    });
}
function buybuy(e)
{
    var send = {};
    send.id = '{$id}';
    var url = "{:U('doc/showbuy')}";
    $.post(url,send,function(res) {
        layer.open({
          type: 1
          ,title: '购买文档'
          ,area: '330px'
          ,shade: 0.1
          ,shadeClose: true
          ,content: [res.data].join('')
        });
        $("#buy_action").click(function()
        {
            buy_action($(this));
        })
    });
}


function buy_action(e)
{
    var url = e.attr('data-url');
    if (!url) {
      if ($(".layui-elem-quote").length && $(".layui-elem-quote").html()) {
        alert($(".layui-elem-quote").html());
        return false;
        
      } else {
 
        layer.msg('您的积分不足以进行此次购买！');
      }
      
      return;
    } else {
      if (url.indexOf('login') != -1) {
          location.href = url;
      }
      else if (url.indexOf('javascript') == -1) {
        var t = layer.confirm('确定购买该文档吗？', {
              btn: ['确定','关闭'] //按钮
            }, function(){
              layer.close(t);
              $.get(url, function() {
                  //layer.msg('购买成功');
                  location.reload();
              })
            });
      }
    }
    
}

function oper(e, type, name, classname)
{
    var send = {};
    send.id = '{$id}';
    send.uid = '{$uid}';
    send.type = type;
    send.typeid = 1;
    var c = e.attr('class');
    if (c.indexOf('active') > -1) {
        e.removeClass(classname);
        e.html(name);
        
        var url = "{:U('common/deloperate')}";
        $.post(url,send,function(res) {
            if (res.status == 1) {
                //layer.msg(res.msg, {time:1800});
            } else {
                layer.msg(res.msg,{time:1800});
                e.addClass(classname);
                e.html('已' + name);
            }
        });
    } else {
        if (classname) {
            e.addClass(classname);
        }
        if (name) {
            e.html('已' + name);
        }
        
        var url = "{:U('common/operate')}";
        $.post(url,send,function(res) {
            if (res.status == 1) {
                //layer.msg(res.msg, {time:1800});
            } else {
                layer.msg(res.msg,{time:1800});
                if (classname) {
                    e.removeClass(classname);
                }
                if (name) {
                    e.html(name);
                }
            }
        });
    }
}

function jubao(e)
{
    var c = e.attr('class');
    if (c.indexOf('active') > -1) {
        var t = layer.confirm('确定取消举报吗？', {
            btn: ['确定','关闭'] //按钮
          }, function(){
            layer.close(t);
            jubao_action(e);
          });
        
    } else {
        layer.prompt({title: '输入举报内容', formType: 2}, function(pass, index){
            layer.close(index);
            jubao_action(e);
        });
    }
}
function jubao_action(e)
{ 
    var send = {};
    send.itemid = '{$id}';
    send.uid = '{$uid}';
    send.typeid = 1;
    var c = e.attr('class');
    if (c.indexOf('active') > -1) {
        e.removeClass('jubao-active layui-btn-primary');
        e.html('举报');
        var url = "{:U('common/ajaxdel_jubao')}";
        $.post(url,send,function(res) {
            if (res.status == 1) {
                //layer.msg(res.msg, {time:1800});
            } else {
                layer.msg(res.msg,{time:1800});
                e.addClass('jubao-active layui-btn-primary');
                e.html('已举报');
            }
        });
    } else {
        var content = $('.layui-layer-input').val();
        if (!content) {
            layer.msg('请填写举报内容',{time:1800});
            return;
        }

        send.content = content;
        e.addClass('jubao-active layui-btn-primary');
        e.html('已举报');
        var url = "{:U('common/ajaxadd_jubao')}";
        $.post(url,send,function(res) {
            if (res.status == 1) {
                //layer.msg(res.msg, {time:1800});
            } else {
                layer.msg(res.msg,{time:1800});
                e.removeClass('jubao-active layui-btn-primary');
                e.html('举报');
            }
        });
    }
}

$(function()
{
    if (option) {
        if (option.type == 1) {
          //加载更多的id
          option.more = "#read_more";
          //阅读器id
          option.reader = "#document";
          //是否显示边框
          option.border = "no";
          //默认显示几页 仅当设置option.more时有效
          option.show = 3;
          Document.Init(option);
      } else if (option.type == 2) {
          option.width = $("#read").width(); //文档容器宽度
          option.zoom = false;              //是否显示放大缩小按钮
          option.zoomStepWidth = 200;
          option.pn = 1;  //定位到第几页，可选
          option.fontSize = 'big';
          option.toolbarConf = {
                  page: true, //上下翻页箭头图标
                  pagenum: true, //几分之几页
                  full: false, //是否显示全屏图标,点击后全屏
                  copy: true, //是否可以复制文档内容
                  position: 'center',// 设置 toolbar中翻页和放大图标的位置(值有left/center)
          }; //文档顶部工具条配置对象,必选
          new Document('document', option);
      }
    }

    star();
    $("#comment").click(function()
    {
        comment($(this));
    });
    $(".shop-collect").click(function()
    {
        oper($(this), 2, '收藏', 'shop-collect-active');
        if ($('.shop-collect-active').length) {
            $(this).addClass('layui-btn-primary');
            $(this).removeClass('layui-bg-blue');
        } else {
            $(this).removeClass('layui-btn-primary');
            $(this).addClass('layui-bg-blue');
        }
    })
    $("#download").click(function()
    {
        download($(this));
    })
    $("#buy").click(function()
    {
        buy($(this));
    })
     $("#buybuy").click(function()
    {
        buy($(this));
    })
    $(".jubao").click(function()
    {
        jubao($(this));
    })
});

</script>
<script>
layui.config({
  version: "3.0.0"
  ,base: '__PUBLIC__/theme/blueideal/mods/' //这里实际使用时，建议改成绝对路径
}).extend({
  fly: 'index'
}).use('fly');
</script>
   

